<?php
require_once('webassist/ecart/checkout/credentials/gateways.php');
?>
<?php
//WA eCart Include
require_once("WA_eCart/ELEVATE954_PHP.php");
?><?php
$ELEVATE954->GetContent();
?>
<?php
require_once("WA_eCart/PP_ECO_Scripts/PP_ECO_PHP.php");
?>
<?php
$WA_PP_ECO_GetResult = WA_PP_ECO_SOAPObject();
if ((isset($_GET["token"]) && isset($_GET["PayerID"])) || (isset($_SESSION["PayPal_ECO_Token"]) && $_SESSION["PayPal_ECO_Token"] != "")) {
  $WA_PP_ECO_GetResult = WA_PP_ECO_Get_Post("setup_api1.soliswebhosting.com", "BTVHHNAKUZNH8TRT", "Al2w1AYQrGr3VAYMgWJDX1ViIuCJA6fcZUv2kgrM73aVPpYYrSYNSxa5", false);
}
?>
<?php require_once("webassist/forms/persist.php"); ?>
<?php
@session_start();
$PPVals = array();
$PPVals["Company"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->PayerBusiness");
$PPVals["First_Name"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->FirstName");
$PPVals["Last_Name"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->LastName");
$PPVals["Address_1"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->Street1");
$PPVals["Address_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->Street2");
$PPVals["City"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->CityName");
$PPVals["State"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->StateOrProvince");
$PPVals["Postal_Code"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->PostalCode");
$PPVals["Country"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->Country");
$PPVals["Phone_Number"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->ContactPhone");
$PPVals["Email_Address"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->Payer");

$PPVals["First_Name_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "ShipToAddress->Name");
$PPVals["Last_Name_2"] = "";
if (strpos($PPVals["First_Name_2"]," ")!==false) {
  $PPVals["Last_Name_2"] = substr($PPVals["First_Name_2"],strpos($PPVals["First_Name_2"]," ")+1);
  $PPVals["First_Name_2"] = substr($PPVals["First_Name_2"],0,strpos($PPVals["First_Name_2"]," "));
}
$PPVals["Address_1_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "ShipToAddress->Street1");
$PPVals["Address_2_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "ShipToAddress->Street2");
$PPVals["City_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "ShipToAddress->CityName");
$PPVals["State_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "ShipToAddress->StateOrProvince");
$PPVals["Postal_Code_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "ShipToAddress->PostalCode");
$PPVals["Country_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "ShipToAddress->Country");
$PPVals["Phone_Number_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "ShipToAddress->Phone");
$PPVals["Email_Address_2"] = WA_PP_ECO_GetValue($WA_PP_ECO_GetResult, "PayerInfo->Payer");

$_SESSION["WASF_CheckoutWizard_ELEVATEcart_ELEVATEcart"] = $PPVals;
?>
<?php
if ($ELEVATE954->IsEmpty())     {
  $ELEVATE954->redirStr = "cart_display.php";
  $ELEVATE954->cartAction = "RedirectIfEmpty";
}
?>
<?php
//WA eCart Include
require_once("WA_eCart/WA_eCart_Database_PHP.php");
?>
<?php
$WA_PP_ECO_DoResult = WA_PP_ECO_SOAPObject();
if ("" == "")  {
  $WA_PP_ECO_Do_required = array();
  $WA_PP_ECO_Do_required[0] = array();
  $WA_PP_ECO_Do_required[1] = array();
  $WA_PP_ECO_Do_itemized = array();
  $WA_PP_ECO_Do_itemized[0] = array();
  $WA_PP_ECO_Do_itemized[1] = array();
  $WA_PP_ECO_Do_optional = array();
  $WA_PP_ECO_Do_optional[0] = array();
  $WA_PP_ECO_Do_optional[1] = array();
  $cartIndex = 0;
  $nextIndex = 0;
  $nextIndex = count($WA_PP_ECO_Do_required[0]);
  $WA_PP_ECO_Do_required[0][$nextIndex] = "Username";
  $WA_PP_ECO_Do_required[1][$nextIndex] = "".($WA_PayPal_PayPal_API_Username)  ."";
  $nextIndex = count($WA_PP_ECO_Do_required[0]);
  $WA_PP_ECO_Do_required[0][$nextIndex] = "Password";
  $WA_PP_ECO_Do_required[1][$nextIndex] = "".($WA_PayPal_PayPal_API_Password)  ."";
  $nextIndex = count($WA_PP_ECO_Do_required[0]);
  $WA_PP_ECO_Do_required[0][$nextIndex] = "Signature";
  $WA_PP_ECO_Do_required[1][$nextIndex] = "".($WA_PayPal_PayPal_API_Signature)  ."";
  $nextIndex = count($WA_PP_ECO_Do_required[0]);
  $WA_PP_ECO_Do_required[0][$nextIndex] = "Token";
  $WA_PP_ECO_Do_required[1][$nextIndex] = "".((isset($_SESSION["PayPal_ECO_Token"]))?$_SESSION["PayPal_ECO_Token"]:"")  ."";
  $nextIndex = count($WA_PP_ECO_Do_required[0]);
  $WA_PP_ECO_Do_required[0][$nextIndex] = "PayerID";
  $WA_PP_ECO_Do_required[1][$nextIndex] = "".((isset($_SESSION["PayPal_ECO_PayerID"]))?$_SESSION["PayPal_ECO_PayerID"]:"")  ."";

  $WA_PP_ECO_Do_itemized[0][0] = "OrderTotal";
  $WA_PP_ECO_Do_itemized[1][0] = "".$ELEVATE954->GrandTotal()  ."";
  $WA_PP_ECO_Do_itemized[0][1] = "OrderDescription";
  $WA_PP_ECO_Do_itemized[1][1] = "";
  while ( !$ELEVATE954->EOF() )      {
  $nextIndex = count($WA_PP_ECO_Do_itemized[0]);
  $WA_PP_ECO_Do_itemized[0][$nextIndex] = "Amount" . strval($cartIndex+1) . "";
  $WA_PP_ECO_Do_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Price")  ."";
  $nextIndex = count($WA_PP_ECO_Do_itemized[0]);
  $WA_PP_ECO_Do_itemized[0][$nextIndex] = "Name" . strval($cartIndex+1) . "";
  $WA_PP_ECO_Do_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Name")  ."";
  $nextIndex = count($WA_PP_ECO_Do_itemized[0]);
  $WA_PP_ECO_Do_itemized[0][$nextIndex] = "Number" . strval($cartIndex+1) . "";
  $WA_PP_ECO_Do_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("ID")  ."";
  $nextIndex = count($WA_PP_ECO_Do_itemized[0]);
  $WA_PP_ECO_Do_itemized[0][$nextIndex] = "Quantity" . strval($cartIndex+1) . "";
  $WA_PP_ECO_Do_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Quantity")  ."";

    $ELEVATE954->MoveNext();
    $cartIndex ++;
  }
  $ELEVATE954->MoveFirst();
  $nextIndex = count($WA_PP_ECO_Do_optional[0]);
  $WA_PP_ECO_Do_optional[0][$nextIndex] = "System";
  $WA_PP_ECO_Do_optional[1][$nextIndex] = "PaymentsPro";
  $nextIndex = count($WA_PP_ECO_Do_optional[0]);
  $WA_PP_ECO_Do_optional[0][$nextIndex] = "PaymentAction";
  $WA_PP_ECO_Do_optional[1][$nextIndex] = "Sale";
  $nextIndex = count($WA_PP_ECO_Do_optional[0]);
  $WA_PP_ECO_Do_optional[0][$nextIndex] = "Currency";
  $WA_PP_ECO_Do_optional[1][$nextIndex] = "USD";
  $nextIndex = count($WA_PP_ECO_Do_optional[0]);
  $WA_PP_ECO_Do_optional[0][$nextIndex] = "ItemTotal";
  $WA_PP_ECO_Do_optional[1][$nextIndex] = "".$ELEVATE954->TotalColumn("TotalPrice")  ."";
  $nextIndex = count($WA_PP_ECO_Do_optional[0]);
  $WA_PP_ECO_Do_optional[0][$nextIndex] = "ShippingTotal";
  $WA_PP_ECO_Do_optional[1][$nextIndex] = "".$ELEVATE954->GetShipping()  ."";
  $nextIndex = count($WA_PP_ECO_Do_optional[0]);
  $WA_PP_ECO_Do_optional[0][$nextIndex] = "HandlingTotal";
  $WA_PP_ECO_Do_optional[1][$nextIndex] = "".($ELEVATE954->GetCharges() - $ELEVATE954->GetDiscounts())  ."";
  $nextIndex = count($WA_PP_ECO_Do_optional[0]);
  $WA_PP_ECO_Do_optional[0][$nextIndex] = "TaxTotal";
  $WA_PP_ECO_Do_optional[1][$nextIndex] = "".$ELEVATE954->GetTax()  ."";

  $WA_PP_ECO_DoResult = WA_PP_ECO_Do_Post($WA_PP_ECO_Do_required,$WA_PP_ECO_Do_itemized,$WA_PP_ECO_Do_optional);
  if (!$WA_PP_ECO_DoResult->isError)  {
    $ELEVATE954->redirStr = "checkout_success.php";
  }
  else if ("checkout_failure.php" != "") {
    header("Location: ". "checkout_failure.php"); exit;
  }
}
?>
<?php 
// WA eCart Store Cart Summary in Db
if ("" == "") // Trigger
{
  $WA_connection = $elevate954;
  $WA_table = "orders";
  $WA_redirectURL = "";
  $WA_indexField = "OrderID";
  $WA_fieldNamesStr = "OrderAmount|OrderShipName|OrderShipAddress|OrderShipAddress2|OrderCity|OrderState|OrderZip|OrderCountry|OrderPhone|OrderShipping|OrderTax|OrderEmail|OrderDate";
  $WA_fieldValuesStr = WA_eCDB_ConvertNumber("".$ELEVATE954->GrandTotal()  ."") . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','First_Name_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','First_Name'))))  ." ".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Last_Name_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Last_Name'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_1_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_1'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_2_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_2'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','City_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','City'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','State_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','State'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Postal_Code_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Postal_Code'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Country_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Country'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Phone_Number_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Phone_Number'))))  ."" . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->GetShipping()  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->GetTax()  ."") . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Email_Address_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Email_Address'))))  ."" . "|" . "".(date('Y-m-d h:i:s'))  ."";
  $WA_columnTypesStr = "none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|none,none,NULL|',none,''|',none,''";
  $WA_sessionName = "ELEVATE954_OrderID";
  $WA_Sql = "";
  $NeedInsert = false;
  $indexFieldIndex = -1;
  $WA_fieldValues = explode("|", $WA_fieldValuesStr);
  $WA_columns = explode("|", $WA_columnTypesStr);
  $WA_connectionDB = $database_elevate954;
  $updateFieldValue = "";
  mysql_select_db($WA_connectionDB, $WA_connection);
  @session_start();
  if ($WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
    $WA_redirectURL .= ((strpos('?', $WA_redirectURL) === false)?"?":"&").$_SERVER["QUERY_STRING"];
  }
  $WA_fieldNames = explode("|", $WA_fieldNamesStr);
  $WA_columns = explode("|", $WA_columnTypesStr);
  for ($i = 0; $i < sizeof($WA_fieldNames); $i++)
  {
    if ($WA_indexField  == $WA_fieldNames[$i])
    {
      $indexFieldIndex = $i;
      break;
    }
  }
  $deleteFieldValue = "";
  $updateColType = "none,none,NULL";
  if ($indexFieldIndex >= 0) $updateFieldValue = $WA_fieldValues[$indexFieldIndex];
  if ($updateFieldValue == "" && isset($_SESSION[$WA_sessionName])) $updateFieldValue = $_SESSION[$WA_sessionName];
  if ($indexFieldIndex >= 0) $updateColType = $WA_columns[$indexFieldIndex];
  if ($updateFieldValue != "")     {
    $updateParamsObj = WA_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, $indexFieldIndex);
    $valueForWhere = WA_generateInsertParams(array($WA_indexField), array($updateColType), array($updateFieldValue), -1);
    $WA_Sql = "update " . $WA_table . " SET " . $updateParamsObj->WA_setValues . " where " . $WA_indexField . " = " . $valueForWhere->WA_dbValues;
    $WA_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
    $_SESSION[$WA_sessionName] = $updateFieldValue;
    $result = mysql_query("SELECT * FROM " . $WA_table . " where " . $WA_indexField . " = " . $valueForWhere->WA_dbValues, $WA_connection);
    $num_rows = mysql_num_rows($result);
    $NeedInsert = (mysql_num_rows($result) === 0);
  }
  if ($updateFieldValue === "" || $NeedInsert)  {
    $updateFieldValue = "";
    $insertParamsObj = WA_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
    $WA_Sql = "insert into " . $WA_table . " (" . $insertParamsObj->WA_tableValues . ") values (" . $insertParamsObj->WA_dbValues . ")";
    $WA_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
    $_SESSION[$WA_sessionName] = mysql_insert_id();
  }
  if ($WA_redirectURL != "")  {
    header("Location: ".$WA_redirectURL); exit;
  }
}
?>
<?php 
// WA eCart Store Cart Details in Db
if ("" == "") // Trigger
{
  $WA_connection = $elevate954;
  $WA_table = "orderdetails";
  $WA_redirectURL = "";
  $WA_indexField = "DetailOrderID";
  $WA_fieldNamesStr = "DetailOrderID|DetailProductID|DetailName|DetailPrice|DetailQuantity";
  $WA_fieldValuesStr = WA_eCDB_ConvertNumber("".((isset($_SESSION["ELEVATE954_OrderID"]))?$_SESSION["ELEVATE954_OrderID"]:"")  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("ID")  ."") . "|" . "".$ELEVATE954->DisplayInfo("Name")  ."" . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("Price")  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("Quantity")  ."");
  $WA_columnTypesStr = "none,none,NULL|none,none,NULL|',none,''|none,none,NULL|none,none,NULL";
  $WA_sql = "";
  mysql_select_db($database_elevate954, $WA_connection);
  $indexFieldIndex = -1;
  $WA_fieldValues = explode("|", $WA_fieldValuesStr);
  @session_start();
  if ($WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
    $WA_redirectURL .= ((strpos('?', $WA_redirectURL) === false)?"?":"&").$_SERVER["QUERY_STRING"];
  }
  $WA_fieldNames = explode("|", $WA_fieldNamesStr);
  $WA_columns = explode("|", $WA_columnTypesStr);
  for ($i = 0; $i < sizeof($WA_fieldNames); $i++)
  {
    if ($WA_indexField  == $WA_fieldNames[$i])
    {
      $indexFieldIndex = $i;
      break;
    }
  }
  $deleteFieldValue = $WA_fieldValues[$indexFieldIndex];
  if (isset($deleteFieldValue) && $deleteFieldValue != "")
  { 
    $deleteParamsObj = WA_generateInsertParams(array($WA_indexField), array($WA_columns[$indexFieldIndex]), array($deleteFieldValue), -1);
    $WA_sql = "Delete from " . $WA_table . " where " . $WA_indexField . " = " . $deleteParamsObj->WA_dbValues;
    $WA_editCmd = mysql_query($WA_sql, $WA_connection) or die(mysql_error());
    $WA_okToDelete = false;
  }
  $ELEVATE954->MoveFirst();
  while (!$ELEVATE954->EOF())
  {
    $WA_fieldValuesStr = WA_eCDB_ConvertNumber("".((isset($_SESSION["ELEVATE954_OrderID"]))?$_SESSION["ELEVATE954_OrderID"]:"")  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("ID")  ."") . "|" . "".$ELEVATE954->DisplayInfo("Name")  ."" . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("Price")  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("Quantity")  ."");
    $WA_fieldValues = explode("|", $WA_fieldValuesStr);
    $insertParamsObj = WA_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
    $WA_sql = "insert into ".$WA_table." (".$insertParamsObj->WA_tableValues.") values (".$insertParamsObj->WA_dbValues.")";
    $WA_editCmd = mysql_query($WA_sql, $WA_connection) or die(mysql_error());
    $ELEVATE954->MoveNext();
  }
  if ($WA_redirectURL != "")  {
    header("Location: ".$WA_redirectURL); exit;
  }
  $ELEVATE954->MoveFirst();
}
?>
<?php
// WA eCart Redirect
if ($ELEVATE954->redirStr != "")     {
  header("Location: ".$ELEVATE954->redirStr);
}
?><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
</body>
</html>